/*
 * reverse.cpp
 *
 *  Created on: Jul 19, 2012
 *      Author: xkq
 */

#include<iostream>
using namespace std;

void remove_duplicates(char *&str){
    if(str==NULL) return;

    int hashTable[256];
    for(int i=0; i<256; i++){
        hashTable[i] = 0;
    }

    char *tmp = str;
    char *p = str;
    while(*tmp!= '\0'){
        if(hashTable[*tmp]==0){
            hashTable[*tmp] == 1;
            *p=*tmp;
            p++;
        }
        tmp++;
    }

    *p='\0';
}

void reverse(char *&str){
    if(str == NULL) return;

    char *p1 = str;
    char *p2 = str;

    while(*p2 != '\0'){
        p2++;
    }

    --p2;

    while(p2>=p1){
        char tmp = *p1;
        *p1=*p2;
        *p2=tmp;
        ++p1;
        --p2;
    }
}

/*int main(char *str)
{
    remove_duplicates(str);
    reverse(str);
    return 0;
}*/


